package cn.mugutu.finance.service.system.impl;

import org.springframework.stereotype.Service;

import cn.mugutu.finance.domain.system.Department;
import cn.mugutu.finance.service.system.DepartmentService;
import cn.mugutu.finance.dto.BaseResult;

@Service
public class DepartmentServiceImpl extends BaseServiceImpl<Department> implements DepartmentService {

    @Override
    public BaseResult saveOrUpdateDepartment(Department department) {
        BaseResult baseResult;
        try {
            if (department.getId() != null) {
                update(department);
                baseResult = new BaseResult(true, "修改成功");
            } else {
                save(department);
                baseResult = new BaseResult(true, "新增成功");
            }
        } catch (Exception e) {
            baseResult = new BaseResult(true, "操作失败");
            e.printStackTrace();
        }
        return baseResult;
    }

}
